<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,java.util.ArrayList,java.util.StringTokenizer,com.scalar.chiptrack.sales.SalesAuditTrail,
com.scalar.chiptrack.commons.SessionKeys,com.scalar.chiptrack.utils.StringUtils,
com.scalar.chiptrack.users.User"
%>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<script language="javascript">

// SharatH on July 31, 2003
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}

</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
 String heading = "";
 String isSample = "1";
%>
<% if((request.getParameter("isSample") != null) && (request.getParameter("isSample").equals("0"))) {
    heading = "Sample "; isSample="0";
%>

<% } else {
    heading = "Sales ";isSample="1";
%>

<% } %>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
</HEAD>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
<center><h2><%=heading%> Order Audit Trail</h2></center>



<!-- from here your body starts -->

<table width='100%' cellpadding='4' cellspacing='4' align='left' border=0>
    <tr><td class="NArailL" colspan='2'><%=heading%>  Audit Trail for - <%=request.getParameter("salesOrderNo")%></td></tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
<!-- donot this...
<logic:iterate id="SalesAuditTrail" name="auditTrail">
    <tr><td colspan='2' class="NArialL"><font size="3">*</font><bean:write name="SalesAuditTrail" property="updatedDate"/>  by <bean:write name="SalesAuditTrail" property="userId"/></td></tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr><td width="10%" class="NArialL">Actions :</td><td class="bodytext"><bean:write name="SalesAuditTrail" property="actions"/></td></tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr><td width='10%' class="NArialL">Comments :</td><td class="bodytext"><bean:write name="SalesAuditTrail" property="comments"/></td></tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
</logic:iterate>
    -->

<%
    ArrayList list = (ArrayList) request.getAttribute("auditTrail");

	//System.out.println("List Size  "+list.size());
try{
    for (int i=0; i < list.size(); i++)
    {

		SalesAuditTrail audit = (SalesAuditTrail)list.get(i);
		//Added  by sarada on 12th Sep 2003 to get Proper labels in Audit trail like Comments and Approer Comments
		String actionss = audit.getActions();
		String commentss = audit.getComments();

       // System.out.println("actionss  "+actionss   );

		boolean flag = false;
		String actions = null;
		String comments = null;
		String actions1 = null;
		String comments1 = null;


		if( (actionss != null) && (actionss.length()!= 0 ))
		{
			int index1 = 0;
			int index2 = 0;

           index1 = actionss.indexOf("^^^###");
          // System.out.println("index12  "+index1);
           if(index1 != -1)
           {
                actions1 = actionss.substring(0,index1);
                comments1 = actionss.substring(index1+6);
                actions = "";
                comments = "";
           }
            else if(index1 == -1 )
           {
               index2 = actionss.indexOf("^^^");
              //System.out.println("index22  "+index2);
                if(index2 != -1)
                {
                  actions = actionss.substring(0,index2);
                  comments = actionss.substring(index2+3);
                }
                else
                {
                    actions = "";
                    comments = "";
                }
                actions1 = "";
                comments1 = "";
           }
          /*  System.out.println("actions1 "+actions1);
            System.out.println("comments1 "+comments1);
            System.out.println("actionss "+actions);
            System.out.println("commentss "+comments);*/
	}



%>
<% if( (( actions != null) && (actions.length()!= 0 )) || (( actions1 != null) && (actions1.length()!= 0 )) || ((comments != null) && (comments.length()!= 0 )) || ((comments1 != null) && (comments1.length()!= 0 )) )  { %>

    <tr><td colspan='2' class="NArialL"><font size="3">*</font><%=audit.getUpdatedDateAsString()%>  by <%=audit.getUserId()%></td></tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <%//Added  by sarada on 12th Sep 2003
		if((( actions != null) && (actions.length()!= 0 )) || ( ( actions1 != null) && (actions1.length()!= 0 ) )) { %>
    <tr><td width="10%" class="NArialL">Actions :</td>
	<% if((actions1 != null) && (actions1.length()!= 0 ) ){ %>
	<td class="bodytext"><font size="-1">
    <%=actions1%></font></td><% }%>
    <%if((actions != null) && (actions.length()!= 0 ) ) { %>
	<td class="bodytext"><font size="-1">
    <%=actions%></font></td><%} %></tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <% } %>

	<% if((comments1 != null) && (comments1.length()!= 0 ) ){%>

     <td width='10%' class="NArialL">Comments :</td><td class="bodytext"><font size="-1"><%=comments1%></font></td>
    <% } %>
    <% if((comments != null) && (comments.length()!= 0 ) ){%>

     <td width='10%' class="NArialL">Approver Comments :</td><td class="bodytext"><font size="-1"><%=comments%></font></td>
    <% } %>
    </tr>






    <tr><td colspan=2><hr></td></tr>
<% } %>


<%
  } //for loop ends here
}catch(Exception e){e.printStackTrace();}
%>
<!-- Added by Sarada on 15th July 2003 to show timestamp and user-->
<tr>
<td  class="NArialL" colspan='2' >User:
<%
User user = (User)session.getAttribute (SessionKeys.USER_KEY);
out.println(user.getUserId());
%></td>
</tr>
<tr>
<td class="NArialL" colspan='2' >Time: <script>document.write(new Date())</script></td>
</tr>

</table>


<!-- till here -->

</BODY>
</HTML>
